home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12667 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.8 KB

  1. Path: ssds.com!usenet
  2. From: Ron Romero <ron.romero@ssds.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: If I were..
  5. Date: Wed, 20 Mar 1996 16:36:24 -0500
  6. Organization: SSDS, Inc.
  7. Distribution: inet
  8. Message-ID: <31507A58.FAD@ssds.com>
  9. References: <4ipb8m$541@gerry.cc.keele.ac.uk>
  10. NNTP-Posting-Host: rem_vie24.ssds.com
  11. Mime-Version: 1.0
  12. Content-Type: text/plain; charset=us-ascii
  13. Content-Transfer-Encoding: 7bit
  14. X-Mailer: Mozilla 2.0 (Win16; I)
  15.  
  16. JS Willans wrote:
  17. > [...]
  18. > I am considering writing the program in pure C++, to get it running on a
  19. > text based platform, and then porting it to the windows platform using
  20. > Bordland C++ 4.0.  Is this making the task of programming for Visual C++
  21. > more difficult, or is this a wise approach?
  22. > In general, writing a program to work with multiple interfaces is a good idea.  
  23. By writing your program first for a text based platform, then for MS Windows, 
  24. you are forcing yourself to split the user interface of your program from the 
  25. underlying implementation.  Making this seperation keeps the internals of your 
  26. program from reflecting the peculiarities of the user interface.  Thus your 
  27. program is more robust, can be adapted for multiple platforms, and can have 
  28. cleaner code.
  29.  
  30. There are a couple of techniques for managing the user interface/ internal 
  31. implementation split. You can physically divide the source code into two 
  32. directories.  This makes the split very obvious and definite.  And, when you add 
  33. new interfaces, you simply add new interface directories.  
  34.  
  35. Also, you should try to keep the first (text based) interface working when you 
  36. port the program to MS Windows.  Do not hack the internal code just to get the 
  37. user interface to work.  If you do find you need to change something, either 
  38. change the text interface as well, or, better yet, make the change incremental. 
  39.  That is, change the internals in such a way that the old code still works.  
  40.  
  41. This is an example of a common pattern in programming, called Model/View. 
  42. (Technically "Model/View/Controller," but most people don't use Controllers")  
  43. The Model is the "internal" code; it is not interface specific.  Your model is 
  44. written in pure C++, without platform extensions.  The View is the user 
  45. interface.  It provides a "view" of the model.  The view knows about the model, 
  46. but the model has absolutely no knowledge of the view.  Thus, you can change out 
  47. views without the model's knowledge, in your example, switching from text to 
  48. windows.
  49.  
  50. > Regards
  51. > James
  52. > ______________________________________________________________________________
  53. > James Willans                                      Music and Computing Student
  54. > University of Keele                                email u5b34@cs.keele.ac.uk
  55. > Keele                                                    u5b34@cc.keele.ac.uk
  56. > Staffordshire
  57.  
  58. Ron Romero
  59. ron.romero@ssds.com
  60. SSDS, Inc.
  61. (signature under construction)
  62.